package com.bert.job;

import com.bert.feign.TestClient;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Slf4j
//@Component
public class TestJob {

    @Resource
    private RestTemplate restTemplate;
    @Resource
    private TestClient testClient;

    @Scheduled(cron = "0/20 * * * * ?")
    public void run() {
        String res = "default param";
        String pathNumber = "test";
        boolean flag = false;
        if (flag) {
            try {
                res = restTemplate.getForObject("http://provider/provider/test/path/" + pathNumber, String.class);
            } catch (Exception ignored) {
            }
        } else {
            res = testClient.path(pathNumber);
        }

        log.info(res);

    }

}
